import com.github.cleverage.elasticsearch.IndexQuery;
import com.github.cleverage.elasticsearch.IndexResults;
import com.github.cleverage.elasticsearch.IndexService;
import indexing.IndexTest;
import indexing.KeywordIndex;

import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.facet.FacetBuilders;
import org.elasticsearch.search.facet.terms.TermsFacet;
import java.util.*;
import play.*;
import play.cache.Cache;
import play.libs.*;


import java.util.*;
import java.util.concurrent.TimeUnit;

import akka.util.Duration;

import com.avaje.ebean.*;

import models.*;

public class Global extends GlobalSettings {
    
    public void onStart(Application app) {
/*    	Cache.set("specialities", specialities);*/    
    	if(IndexService.existsIndex()){
    		IndexService.deleteIndex();
    	}
        KeywordIndex keywordIndex = new KeywordIndex();
    	List<Specialities> specialities = Specialities.getAllSpecialities();
    	for(Specialities speciality: specialities){
    		String[] keywords = speciality.keywords.split(";");
    		for(String keyword : keywords){
    			keywordIndex.keywords=keyword;
    			keywordIndex.index();
    		}
    	}
    }
    
    
}